<template>
  <a-form ref="formRef" :model="formData.data" :label-col="labelCol">
    <a-row>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.transferCreditPolicy')">
          <a-select v-model:value="formData.data.schCreditTransferPolicy" placeholder="请选择">
            <a-select-option v-for="item in dictLists.data[dictEnum.TRANSFER_POLICY]"
                             :value="item.value"
                             :key="item.value"
            >
              {{ item.label }}
            </a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.other')" v-if="Number(formData.data.schCreditTransferPolicy) === 3">
          <a-input v-model:value="formData.data.schCreditTransferPolicyother	" placeholder="请输入"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.transferCredit')">
          <a-input v-model:value="formData.data.schCreditTransferRequirements" placeholder="请输入"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.GPA')">
          <a-input v-model:value="formData.data.schGpaRequirements" placeholder="请输入"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.gradeRequire')">
          <a-input v-model:value="formData.data.schPerformanceRequirements" placeholder="请输入"/>
        </a-form-item>
      </a-col>
      <a-col :span="12">
        <a-form-item :label="t('school-manage.label.creditLimit')">
          <a-input v-model:value="formData.data.schCreditLimit" placeholder="请输入"/>
        </a-form-item>
      </a-col>
      <a-col :span="24">
        <a-form-item :label="t('school-manage.label.remark')" :label-col="{ span: 2 }">
          <a-input v-model:value="formData.data.schRemarks" placeholder="请输入"/>
        </a-form-item>
      </a-col>
    </a-row>
  </a-form>
</template>

<script setup>
import { defineExpose, reactive, ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { getDictByCodesReturnObj } from "@/tools/get-dict"
import dictEnum from "@/const/dict"

const { t } = useI18n()
const labelCol = { span: 4 }
const formRef = ref()
const formData = reactive({
  data: {}
})

const submit = () => {
  return new Promise(resolve => {
    formRef.value
      .validate()
      .then(() => {
        resolve(formData.data)
      })
  })
}

const dictLists = reactive({
  data: {},
  code: [dictEnum.TRANSFER_POLICY]
})

onMounted(async () => {
  dictLists.data = await getDictByCodesReturnObj(dictLists.code)
})

const updateFormData = data => {
  formData.data = data
}

defineExpose({
  submit,
  updateFormData
})
</script>

<style scoped>

</style>
